<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Hello World</title>
  <script src="https://unpkg.com/vue"></script>

</head>

<body>
  <div id="root"></div>
  <script>
    /* 
      1. 单根元素的组件，没有通过props接收的参数，会应用到组件根元素上
      2. inheritAttrs: false 关闭继承
      3. 应用场景：
      - 传递样式给组件
      4. 多根元素的组件，通过v-bind="$attrs"绑定传递过来的参数
    */
    const counter = {
      inheritAttrs: false,
      template: `<div>
      <p>Non Props</p>
    </div>`
    }
    const demo = {
      props: ['dataText'],
      template: `
      <p>Non Props1</p>
      <p v-bind="$attrs">Non Props2</p>
      <p>Non Props3</p>
      `
    }
    const app = Vue.createApp({
      components: {
        counter,
        demo
      },
      template: `<div>
        <counter data-text="hello"/>
        <demo data-text="hello" data-time="2025-01-31 21:03:51"/>
      </div>`
    })

    const vm = app.mount('#root');
  </script>
</body>

</html>